package com.stu.stusystem.model.system;

import com.stu.stusystem.common.BaseModel;
import com.stu.stusystem.model.em.Jurisdiction;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;

/**
 * @author cxt
 * @date 2020/9/7
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "stu_user")
public class StuUser extends BaseModel {
    @Id
    private String id;

    @NotBlank(message = "用户名不能为空")
    @Column(name = "name")
    private String name;

    @NotBlank(message = "账号不能为空")
    @Column(name = "account")
    private String account;

    @Column(name = "class_id")
    private String classId;

    @NotBlank(message = "密码不能为空")
    @Column(name = "password")
    private String password;

    @Column(name = "phone")
    private String phone;

    @Column(name = "id_card")
    private String idCard;

    @Column(name = "head_img")
    private String headImg;

    // 身份标识：STUDENT（普通学生）,INSTRUCTOR（辅导员）,HOUSEMASTER（宿管）,LEADER（领导）,ADMIN（超级管理）
    @Column(name = "jurisdiction")
    private Jurisdiction jurisdiction;

    public StuUser(String account) {
        this.account = account;
    }

    public StuUser(String id, String account, String name, String password, Jurisdiction jurisdiction) {
        this.id = id;
        this.account = account;
        this.name = name;
        this.password = password;
        this.jurisdiction = jurisdiction;
    }

    public StuUser setAccount(String account) {
        this.account = account;
        return this;
    }
}
